<template>
  <div :class="{
    'user-profile':true,
    'item_is_group':info.type == 'groups',
    'item_is_user':info.type='user'
    }" 
  v-if="show_card"  >
    <div class="card-header">
      <h2 class="username">{{ userData?.data?.username || userData?.data?.group_name || '' }}</h2>
      <button @click="show_card=!show_card" class="toggle-button">
        {{ show_card ? '关闭' : '' }}
      </button>
    </div>

    <div class="card-body">
      <div class="avatar-container">
        <img :src="userData?.data?.head_image || '/public/yonghu.png'" alt="用户头像" class="avatar" />
      </div>
      <div class="info-list">
        <div class="info-item" v-if="userData?.data?.age != undefined ">
          <span class="info-label">年龄:</span>
          <span class="info-value">{{userData?.data?.age }}</span>
        </div>
        <div class="info-item" v-if="userData?.data?.sex != undefined">
          <span class="info-label">性别:</span>
          <span class="info-value">{{ userData?.data?.sex }}</span>
        </div>
        <div class="info-item" v-if="userData?.data?.id">
          <span class="info-label">ID:</span>
          <span class="info-value">{{ userData?.data?.id }}</span>
        </div>
        <div class="info-item" v-if="userData?.data?.introduction">
          <span class="info-label">个人简介:</span>
          <p class="info-value">{{ userData?.data?.introduction || '这个人很懒，什么也没有留下~' }}</p>
        </div>
      </div>
    </div>

  </div>
</template>

<script setup>
import { reactive,defineModel, onMounted } from 'vue';
const info = defineModel('current_interact_info',)
let show_card = defineModel('show_info_card')
const userData = reactive({ ...info.value });
onMounted(() => { 
  console.log(info.value)
})




</script>

<style scoped>
.user-profile {
  width: 250px;
  margin: 20px auto;
  padding: 15px;
  border-radius: 10px;
  background: white;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease;
  user-select: none;
  z-index: 101;
}
.user-profile:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.username {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin: 0;
  white-space: nowrap;      
  overflow: hidden;        
  text-overflow: ellipsis;  
}

.avatar-container {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 15px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}
.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  text-align: center;
}

.info-list {
  margin-top: 10px;
}
.info-item {
  display: flex;
  justify-content: space-between;
  margin: 8px 0;
}
.info-label {
  font-weight: 600;
  color: #555;
  font-size: 14px;
  white-space: nowrap;      
  overflow: hidden;          
  text-overflow: ellipsis;   
}
.info-value {
  font-size: 14px;
  color: #333;
  white-space: nowrap;       
  overflow: hidden;         
  text-overflow: ellipsis;  
}

.toggle-button {
  padding: 6px 12px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  color: white;
  background-color: #007bff;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
.toggle-button:hover {
  background-color: #0056b3;
}

.item_is_user {
  background: rgba(255, 255, 255, 0.2); /* 半透明底色 */
  border-radius: 8px; /* 圆角 */
  box-shadow: 
    0 4px 30px rgba(0, 0, 0, 0.1), /* 外部阴影 */
    inset 0 0 10px rgba(255, 255, 255, 0.5); /* 内部高光 */
  backdrop-filter: blur(5px); /* 背景模糊效果 */
  border: 1px solid rgba(255, 255, 255, 0.3); /* 半透明边框 */
  position: relative;
  overflow: hidden;
}
.item_is_group{
  background: rgba(255, 255, 255, 0.2); 
}

/* 添加光泽效果 */
.item_is_user::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0) 40%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(30deg);
  animation: shine 5s infinite;
}

/* 光泽动画 */
@keyframes shine {
  0% {
    transform: rotate(30deg) translate(-30%, -30%);
  }
  100% {
    transform: rotate(30deg) translate(30%, 30%);
  }
}
</style>